import { WordSegmentationManagement as locale } from './locale';
import {
  createInbizSchema,
  createComponentStyleSchema,
  createDecoratorStyleSchema,
} from '@inbiz/setters';

export const configuration = [
  {
    id: 'synonym',
    title: 'WordSegmentationManagement.synonym',
    isEdit: true,//修改
    isHide: true,//隐藏
    isDel: false,
  },
  {
    id: 'extendedWord',
    title: 'WordSegmentationManagement.extendedWord',
    isEdit: true,
    isHide: true,
    isDel: false,
  },
  {
    id: 'stopWord',
    title: 'WordSegmentationManagement.stopWord',
    isEdit: true,
    isHide: true,
    isDel: false,
  },
  {
    id: 'regularWordSegmentationConfiguration',
    title: 'WordSegmentationManagement.regular',
    isEdit: true,
    isHide: true,
    isDel: false,
  },
];

export const defaultProps = {
  GetPage: '20条/页',
  configuration,
};

export const Schema = createInbizSchema({
  attribute: {
    base: {
      type: 'void',
      'x-component': 'CollapseItem',
      properties: {
        'x-display': {
          type: 'string',
          enum: ['visible', 'hidden'],
          'x-decorator': 'FormItem',
          'x-component': 'Select',
          'x-component-props': {
            defaultValue: 'visible',
          },
        },
        'x-component-props': {
          type: 'object',
          properties: {
            //分页数
            GetPage: {
              type: 'array',
              'x-decorator': 'FormItem',
              'x-component': 'Select',
              enum: [10, 20, 30, 50, 100],
            },
            configuration: {
              type: 'array',
              'x-decorator': 'FormItem',
              'x-component': 'DataSource',
              // 根据配置显示
              'x-component-props': {
                config: {
                  // 标题
                  title: true,
                  hideAddBtn: true,
                  isHide:true
                },
                // 新建时表单默认值
                default: {
                  processGroup: true,
                },
                defaultValue: configuration,
              },
            },
          },
        },
      },
    },
  },
  style: {
    ...createComponentStyleSchema(),
    ...createDecoratorStyleSchema(),
  },
});

export const defaultResource = {
  icon: 'WordManagement',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'string',
        title: {
          value: 'WordSegmentationManagement.title',
          status: true,
        },
        'x-decorator': 'Container',
        'x-component': 'WordSegmentationManagement',
        'x-component-props': defaultProps,
      },
    },
  ],
};

export const defaultBehavior = {
  name: 'WordSegmentationManagement',
  extends: ['Field'],
  selector: (node: any) => node.props['x-component'] === 'WordSegmentationManagement',
  designerProps: { propsSchema: Schema },
  designerLocales: locale,
};
